//
//  OrderDetailProductCell.m
//  Ufan
//
//  Created by yangqingluo on 15/12/28.
//  Copyright © 2015年 yangqingluo. All rights reserved.
//

#import "OrderDetailProductCell.h"
#import "UIImageView+EMWebCache.h"

@interface OrderDetailProductCell()

@property (strong, nonatomic) UIView *bottomLineView1;

@end

@implementation OrderDetailProductCell

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.textLabel.font = [UIFont boldSystemFontOfSize:14.0];
        
        self.detailTextLabel.font = [UIFont systemFontOfSize:14.0];
        self.detailTextLabel.textColor = [UIColor lightGrayColor];
        self.detailTextLabel.textAlignment = NSTextAlignmentLeft;
        
        _bottomLineView1 = [[UIView alloc] init];
        _bottomLineView1.backgroundColor = UFCOLOR_GRAYLINE;
        [self.contentView addSubview:_bottomLineView1];
        

        
    }
    return self;
}

-(void)layoutSubviews{
    [super layoutSubviews];
    
    _bottomLineView1.frame = CGRectMake(15, self.contentView.height - 1, self.width - 30, 1);
    
    self.imageView.frame = CGRectMake(_bottomLineView1.left, 20, 80, 60);
    self.textLabel.frame = CGRectMake(self.imageView.right + 20, self.imageView.top + 10, _bottomLineView1.right - self.imageView.right - 20, 20);
    self.detailTextLabel.frame = CGRectMake(self.textLabel.left, self.textLabel.bottom, self.textLabel.width, self.textLabel.height);
    
    if (self.order.productItems.count) {
        UFProductItem *item = self.order.productItems[0];
        
        NSURL *imageUrl = [NSURL URLWithString:item.mainUrl];
        [self.imageView sd_setImageWithURL:imageUrl placeholderImage:[UIImage imageNamed:@""]];
        
        self.detailTextLabel.text = [NSString stringWithFormat:@"单价：%.2f元",item.itemPrice];
        self.textLabel.text = item.productName;
    }

    
}


+(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 100.0;
}

@end
